package com.example.service.controller;


import com.example.helloserviceapi.model.User;
import com.example.helloserviceapi.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController implements HelloService {

    @Autowired
    DiscoveryClient discoveryClient;

    @RequestMapping("123")
    public String hello(){
        ServiceInstance localServiceInstance = discoveryClient.getLocalServiceInstance();
        System.out.println("***" + localServiceInstance.getServiceId());
        return "hello, this is service2";
    }

    @Override
    public String hello2() {
        return "hello service";
    }

    @Override
    public User pringUser(@RequestBody User user) {
        System.out.println("接收到的参数："+user);
        return user;
    }

    @Override
    public String sout(@RequestBody String string) {
        System.out.println("接收到的字符串参数：" + string);
        return string;
    }
}
